cmake_minimum_required(VERSION 3.9)
project(libdisasm C)

set(CMAKE_DEBUG_POSTFIX d)
set(src_path ${CMAKE_CURRENT_SOURCE_DIR}/../breakpad/src/third_party/libdisasm)

set(SRCS
        ${src_path}/ia32_implicit.c
        ${src_path}/ia32_implicit.h
        ${src_path}/ia32_insn.c
        ${src_path}/ia32_insn.h
        ${src_path}/ia32_invariant.c
        ${src_path}/ia32_invariant.h
        ${src_path}/ia32_modrm.c
        ${src_path}/ia32_modrm.h
        ${src_path}/ia32_opcode_tables.c
        ${src_path}/ia32_opcode_tables.h
        ${src_path}/ia32_operand.c
        ${src_path}/ia32_operand.h
        ${src_path}/ia32_reg.c
        ${src_path}/ia32_reg.h
        ${src_path}/ia32_settings.c
        ${src_path}/ia32_settings.h
        ${src_path}/libdis.h
        ${src_path}/qword.h
        ${src_path}/x86_disasm.c
        ${src_path}/x86_format.c
        ${src_path}/x86_imm.c
        ${src_path}/x86_imm.h
        ${src_path}/x86_insn.c
        ${src_path}/x86_misc.c
        ${src_path}/x86_operand_list.c
        ${src_path}/x86_operand_list.h
)

include_directories(src_path)

add_library(libdisasm ${SRCS})

if (MSVC)
    target_compile_definitions(libdisasm PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()

install(
        TARGETS libdisasm
        RUNTIME DESTINATION bin
        LIBRARY DESTINATION lib
        ARCHIVE DESTINATION lib
)

if(NOT DISABLE_INSTALL_HEADERS)
    install(FILES libdisasm/libdis.h DESTINATION include)
endif()
